<html xmlns="http://www.w3.org/1999/xhtml"          			
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"  
      xmlns:f="http://java.sun.com/jsf/core"
      >
    <ui:composition template="TaskProLayout.xhtml">
        <ui:define name="content">
            <!--Filter form START -->
            <div class="Post">
                <h:form>
                    <div class="gridLayout">
                        <p:panel  id="pnl" header="Filter" toggleable="true" collapsed="true"  toggleSpeed="100" closeSpeed="100" widgetVar="panel">  

                            <h:panelGrid id="filter" columns="6" cellpadding="9" title="Filter">  

                                <h:outputText value="Type of task" />
                                <p:selectCheckboxMenu value="#{studentTaskBean.selectedTypes}" label="Type" >  
                                    <f:selectItems value="#{studentTaskBean.types}" />  
                                </p:selectCheckboxMenu> 
                                <h:outputText value="Submit task" />
                                <p:selectBooleanButton value="#{studentTaskBean.submitTask}" onLabel="Yes" offLabel="No" />  
                                <h:outputText value="Unsubmit task" />
                                <p:selectBooleanButton value="#{studentTaskBean.unSubmitTask}" onLabel="Yes" offLabel="No" />  
                            </h:panelGrid>
                            <p:commandButton value="Apply filter"  action="#{studentTaskBean.applyFilter()}" ajax="true" update=":task:assignmentTable"/>   

                        </p:panel>  
                    </div>
                </h:form>       
            </div>
            <!--Filter form END -->
            <!--Task to submit summarization dataTable START -->
            <div class="Post">
                <h:form id="task">
                    <p:dataTable 
                        var="task" value="#{studentTaskBean.taskToSubmit}" paginator="true" rows="10"  
                        selection="#{studentTaskBean.taskChoosen}" selectionMode="single"  
                        rowKey="#{task.id}" paginatorAlwaysVisible="false"
                        widgetVar="taskTable" id="assignmentTable"
                        >  
                        <p:ajax event="rowSelect"  
                                update=":submit"  oncomplete="taskDialog.show()" />    
                        <f:facet name="header">  
                            <h:outputText value="Tasks to submit" />
                        </f:facet>  
                        <p:column headerText="Assignment" >  
                            <h:outputText value="#{task.template.name}" >
                                <f:converter converterId="StringConverter" />
                            </h:outputText>
                        </p:column>   
                        <p:column headerText="Description">  
                            <h:outputText value="#{task.template.description}" >
                                <f:converter converterId="StringConverter" />
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Date of assignment">    
                            <h:outputText value="#{task.dateOfAssignment}" >
                                <f:convertDateTime type="both" timeZone="Europe/Prague"></f:convertDateTime>
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Deadline">  
                            <h:outputText value="#{task.deadline}" >
                                <f:convertDateTime type="both" timeZone="Europe/Prague"></f:convertDateTime>
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Type">                      
                            <h:outputText value="#{task.type}" /> 
                        </p:column>
                        <p:column headerText="Kantor">            
                            <h:outputText value="#{task.template.kantor.name} #{task.template.kantor.surname}" /> 
                        </p:column>
                        <p:column headerText="Subject">   
                            <h:outputText value="#{task.subject.code}" /> 
                        </p:column>
                    </p:dataTable>   
                    <h:outputText value="To select or unselect use CTRL" />
                </h:form>      
                <!--Task to submit summarization dataTable END -->

                <!--Selected task to submit detail dialog START -->
                <p:dialog header="Task Detail" widgetVar="taskDialog" resizable="true" 
                          width="900" height="600" dynamic="true" appendToBody="true"  modal="true"> 
                    <h:form id="submit">
                        <h:panelGrid id="display" columns="2" cellpadding="4" title="Assigned Task">  
                            <h:outputText value="Label"/>
                            <h:outputText value="#{studentTaskBean.taskChoosen.template.name}" />
                            <h:outputText value="Description"/>
                            <h:outputText value="#{studentTaskBean.taskChoosen.template.description}" escape="false" >
                                <f:converter converterId="StringFormatter"/>
                            </h:outputText>
                            <h:outputText value="Date of assignment"/>
                            <h:outputText value="#{studentTaskBean.taskChoosen.dateOfAssignment}" >
                                 <f:convertDateTime type="both" timeZone="Europe/Prague"></f:convertDateTime>
                            </h:outputText>
                            <h:outputText value="Deadline"/>
                            <h:outputText value="#{studentTaskBean.taskChoosen.deadline}" >
                                <f:convertDateTime type="both" timeZone="Europe/Prague"></f:convertDateTime>
                            </h:outputText>
                            <h:outputText value="Kantor:"/>                           
                            <h:outputText value="#{studentTaskBean.taskChoosen.template.kantor.name} 
                                          #{studentTaskBean.taskChoosen.template.kantor.surname}" />
                            <h:outputText value="Kantor e-mail:" />
                            <h:outputText value="#{studentTaskBean.taskChoosen.template.kantor.email}" />
                        </h:panelGrid>  
                        <p:dataTable id="templateFileTable" value="#{studentTaskBean.taskChoosen.template.templateFiles}" var="tFile"
                                     rowKey="#{tFile.id}" emptyMessage="No files were added to this task by kantor">
                            <f:facet name="header">
                                <h:outputText value="Assignment files" />
                            </f:facet>
                            <p:column headerText="File name">
                                <h:outputText value="#{tFile.fileName}" />
                            </p:column>
                            <p:column headerText="File size">
                                <h:outputText value="#{tFile.fileSize}" />
                            </p:column>
                            <p:column headerText="Action">
                                <p:commandButton value="Download" ajax="false">
                                    <p:fileDownload id="koko" value="#{studentTaskBean.download(tFile)}"/>
                                </p:commandButton>    
                            </p:column>
                        </p:dataTable>
                        <p:commandButton value="Submit"  action="#{studentTaskBean.submitTask()}" 
                                         ajax="false"></p:commandButton>
                        <p:commandButton value="Close" onclick="taskDialog.hide()"
                                         ajax="true"></p:commandButton>
                    </h:form>
                </p:dialog>   
            </div>
            <!--Selected task to submit detail dialog END -->

        </ui:define>
    </ui:composition>
</html>